import { h } from 'vue'
import businessService from '@/api/business/index.js'
import customerInformationService from '@/api/customerInformation/index.js'
import DictTag from '@/components/DictTag/index.vue'
import { useDict } from '@/utils/dict.js'

const { sys_annual_type, sys_pay_type, gf_record_status, discount_rate, annual_fee_discount_rate,confirm_discount_rate } = useDict('sys_annual_type', 'sys_pay_type', 'gf_record_status', 'discount_rate', 'annual_fee_discount_rate','confirm_discount_rate')
const customersData = await customerInformationService.getQueryList()
const businessData = await businessService.list()

export const yearFeeSearchConfig = [
  {
    label: '合同编号',
    field: 'contractNo',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '客户名称',
    field: 'customId',
    type: 'select',
    defaultShow: true,
    options: {
      data: customersData?.data,
      label: 'customerName',
      value: 'customerId',
    },
  },
  {
    label: '案件编号',
    field: 'patentNo',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '业务名称',
    field: 'patentName',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '业务类型',
    field: 'patentType',
    type: 'select',
    defaultShow: true,
    options: {
      data: businessData?.rows,
      label: 'businessName',
      value: 'businessId',
    },
  },
  {
    label: '缴费节点',
    field: 'feeNode',
    type: 'select',
    defaultShow: true,
    options: {
      data: sys_annual_type,
    },
  },
  {
    label: '缴费截止日期',
    field: 'feeDeadline',
    defaultShow: true,
    type: 'daterange',
  },
  {
    label: '实际缴费日期',
    field: 'actualFeeDate',
    defaultShow: true,
    type: 'daterange',
  },
  {
    label: '缴费方式',
    field: 'feeType',
    type: 'select',
    options: {
      data: sys_pay_type,
    },
  },
  {
    label: '备注',
    field: 'remark',
    type: 'input',
    showOverflow: 'tooltip',
  },
  {
    label: '申请号',
    field: 'applyNumber',
    type: 'input',
  },
]
export const yearFeeFjSearchConfig = [
  {
    label: '合同编号',
    field: 'contractNo',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '客户名称',
    field: 'customId',
    type: 'select',
    defaultShow: true,
    options: {
      data: customersData?.data,
      label: 'customerName',
      value: 'customerId',
    },
  },
  {
    label: '案件编号',
    field: 'patentNo',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '业务名称',
    field: 'patentName',
    type: 'input',
    defaultShow: true,
  },
  {
    label: '业务类型',
    field: 'patentType',
    type: 'select',
    defaultShow: true,
    options: {
      data: businessData?.rows,
      label: 'businessName',
      value: 'businessId',
    },
  },
  {
    label: '备注',
    field: 'remark',
    type: 'input',
    showOverflow: 'tooltip',
  },
  {
    label: '申请号',
    field: 'applyNumber',
    type: 'input',
  },
]

export const yearFeeTableColumns = [
  {
    type: 'checkbox',
    width: 60,
    align: 'center',
  },
  {
    type: 'seq',
    minWidth: 60,
    align: 'center',
  },
  {
    title: '客户名称',
    field: 'customerName',
    align: 'center',
    minWidth: 200,
  },
  {
    title: '合同编号',
    field: 'contractNo',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '案件编号',
    field: 'patentNo',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '申请号',
    field: 'applyNumber',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '业务名称',
    field: 'patentName',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '业务类型',
    align: 'center',
    field: 'patentType',
    minWidth: 120,
  },
  {
    title: '缴费节点',
    field: 'feeNode',
    align: 'center',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: sys_annual_type.value,
          value: row.feeNode,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '年度',
    align: 'center',
    field: 'year',
    minWidth: 80,
  },
  {
    title: '月度',
    align: 'center',
    field: 'lateMonth',
    minWidth: 80,
  },
  {
    title: '代缴费用',
    align: 'center',
    field: 'amount',
    minWidth: 100,
  },
  {
    title: '费减比例',
    align: 'center',
    field: 'discountRate',
    minWidth: 100,
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: confirm_discount_rate.value,
          value: row.discountRate,
        })
      },
    },
  },
  {
    title: '状态',
    field: 'status',
    align: 'center',
    slots: {
      // default: 'status',
      default: ({ row }) => {
        return h(DictTag, {
          options: gf_record_status.value,
          value: row.status,
        })
      },
    },
    minWidth: 80,
  },
  {
    title: '缴费截止日',
    field: 'deadline',
    align: 'center',
    minWidth: 180,
    formatter: ({ cellValue }) => {
      return cellValue ? cellValue.split(' ')[0] : ''
    },
  },
  {
    title: '实际缴费日期',
    field: 'paymentTime',
    align: 'center',
    minWidth: 180,
    formatter: ({ cellValue }) => {
      return cellValue ? cellValue.split(' ')[0] : ''
    },
  },
  {
    title: '缴费方式',
    field: 'feeType',
    align: 'center',
    slots: {
      // default: 'feeType',
      default: ({ row }) => {
        return h(DictTag, {
          options: sys_pay_type.value,
          value: row.feeType,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '备注',
    field: 'remark',
    align: 'center',
    minWidth: 150,
    showOverflow: 'tooltip',
  },
  {
    title: '操作',
    field: 'actions',
    align: 'center',
    minWidth: 227,
    slots: {
      default: 'actions',
    },
    fixed: 'right',
  },
]
export const yearFeeJfdTableColumns = [
  {
    type: 'seq',
    minWidth: 60,
    align: 'center',
  },
  {
    title: '客户名称',
    field: 'customerName',
    align: 'center',
    minWidth: 200,
  },
  {
    title: '合同编号',
    field: 'contractNo',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '案件编号',
    field: 'patentNo',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '申请号',
    field: 'applyNumber',
    align: 'center',
    minWidth:1
  },
  {
    title: '业务名称',
    field: 'patentName',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '业务类型',
    align: 'center',
    field: 'patentType',
    minWidth: 120,
  },
  {
    title: '缴费节点',
    field: 'feeNode',
    align: 'center',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: sys_annual_type.value,
          value: row.feeNode,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '年度',
    align: 'center',
    field: 'year',
    minWidth: 80,
  },
  {
    title: '月度',
    align: 'center',
    field: 'lateMonth',
    minWidth: 80,
  },
  {
    title: '代缴费用',
    align: 'center',
    field: 'amount',
    minWidth: 100,
  },
  {
    title: '费减比例',
    align: 'center',
    field: 'feeReduceRate',
    minWidth: 100,
  },
  {
    title: '状态',
    field: 'status',
    align: 'center',
    slots: {
      // default: 'status',
      default: ({ row }) => {
        return h(DictTag, {
          options: gf_record_status.value,
          value: row.status,
        })
      },
    },
    minWidth: 80,
  },
  {
    title: '缴费截止日',
    field: 'deadline',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '实际缴费日期',
    field: 'paymentTime',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '缴费方式',
    field: 'feeType',
    align: 'center',
    slots: {
      // default: 'feeType',
      default: ({ row }) => {
        return h(DictTag, {
          options: sys_pay_type.value,
          value: row.feeType,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '备注',
    field: 'remark',
    align: 'center',
    minWidth: 150,
    showOverflow: 'tooltip',
  },
]

export const yearFeeFjTableColumns = [
  {
    type: 'checkbox',
    width: 60,
    align: 'center',
  },
  {
    type: 'seq',
    minWidth: 60,
    align: 'center',
  },
  {
    title: '客户名称',
    field: 'customerName',
    width: 150,
    align: 'center',
  },
  {
    title: '合同编号',
    field: 'contractNo',
    minWidth: 90,
    align: 'center',
  },
  {
    title: '案件编号',
    field: 'patentNo',
    minWidth: 100,
    align: 'center',
  },
  {
    title: '申请号',
    field: 'applyNumber',
    minWidth: 80,
    align: 'center',
  },
  {
    title: '业务名称',
    field: 'patentName',
    minWidth: 140,
    align: 'center',
  },
  {
    title: '业务类型',
    field: 'patentType',
    align: 'center',
    minWidth: 130,
  },
  {
    title: '费减开始年度',
    field: 'discountStartYear',
    align: 'center',
    minWidth: 80,
  },
  {
    title: '费减比例',
    field: 'discountRate',
    align: 'center',
    minWidth: 50,
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: confirm_discount_rate.value,
          value: row.discountRate,
        })
      },
    },
  },
  {
    title: '备注',
    field: 'remark',
    align: 'center',
    minWidth: 100,
    showOverflow: 'tooltip',
  },
  {
    title: '操作',
    minWidth: 150,
    align: 'center',
    fixed: 'right',
    slots: {
      default: 'actions',
    },
  },
]
